<html>
<head>
  <title>Time - Test Cases</title>
</head>
<body>

<script src="../lib/time.js"></script>
<script type="text/javascript">
if (!(window.Time && window.Time.Version)) {

document.writeln("Time doesn't exist. Build with Ruby/Rake.");

} else {

document.write('<pre style="font-size:11px;">');

document.writeln('================================================================================');
document.writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
document.writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Date/Time Manipulation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
document.writeln('================================================================================');
document.writeln('');

document.writeln('Version : ', Time.Version);
document.writeln('');

document.writeln('');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('======================================================================= LANGUAGE');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('');

document.writeln('Default Language:      ', Time.lang());
document.writeln('Supported Languages:   ', Time.langList());
document.writeln('');
document.writeln('Set Language to de:    ', Time.langSet('de'));
document.writeln('Set Language to en:    ', Time.langSet('en'));
document.writeln('Set Language to es:    ', Time.langSet('es'));
document.writeln('Set Language to fr:    ', Time.langSet('fr'));
document.writeln('');
document.writeln('Detected Language:     ', Time.langDetect());
document.writeln('Set Detected Language: ', Time.langSetDetect());
document.writeln('');
document.writeln('Reset Language:        ', Time.langReset());
document.writeln('');

document.writeln('');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('====================================================================== ABS | UTC');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('');

document.writeln('Absolute Dates:');
document.writeln('');
document.writeln('new Date(0, 0, 1, 0, 0, 0, 0)  //=> ', Time.phpdate('r', new Date(0, 0, 1, 0, 0, 0, 0)));
document.writeln('Time.abs(0, 0, 1, 0, 0, 0, 0)  //=> ', Time.phpdate('r', Time.abs(0, 0, 1, 0, 0, 0, 0)));
document.writeln('');
document.writeln('Date.UTC(0, 0, 1, 0, 0, 0, 0)  //=> ', Time.phputc('r', Date.UTC(0, 0, 1, 0, 0, 0, 0)));
document.writeln('Time.utc(0, 0, 1, 0, 0, 0, 0)  //=> ', Time.phputc('r', Time.utc(0, 0, 1, 0, 0, 0, 0)));
document.writeln('');
document.writeln('// notice the lack of assumptions and auto-corrections (e.g., 0 => 1900)');
document.writeln('');
document.writeln('');
document.writeln('All parameters are optional:');
document.writeln('');
document.writeln('Time.abs()  //=> ', Time.phpdate('r', Time.abs()));
document.writeln('Time.utc()  //=> ', Time.phputc('r', Time.utc()));
document.writeln('');
document.writeln('Time.abs(2008, 10, 1, 16, 14)  //=> ', Time.phpdate('r', Time.abs(2008, 10, 1, 16, 14)));
document.writeln('Time.utc(2008, 10, 1, 16, 14)  //=> ', Time.phputc('r', Time.utc(2008, 10, 1, 16, 14)));
document.writeln('');
document.writeln('');
document.writeln('Ranges: (both PHPDATE and STRFTIME)');
document.writeln('');
document.writeln('phpdate("c",   Time.abs(   0,  0,  1,  0,  0,  0,   0))  //=> ', Time.phpdate("c",   Time.abs(   0,  0,  1,  0,  0,  0,   0)));
document.writeln('phpdate("c",   Time.abs(9999, 11, 31, 23, 59, 59, 999))  //=> ', Time.phpdate("c",   Time.abs(9999, 11, 31, 23, 59, 59, 999)));
document.writeln('strftime("%c", Time.abs(   0,  0,  1,  0,  0,  0,   0))  //=> ', Time.strftime("%c", Time.abs(   0,  0,  1,  0,  0,  0,   0)));
document.writeln('strftime("%c", Time.abs(9999, 11, 31, 23, 59, 59, 999))  //=> ', Time.strftime("%c", Time.abs(9999, 11, 31, 23, 59, 59, 999)));
document.writeln('');
document.writeln('phputc("c",   Time.utc(   0,  0,  1,  0,  0,  0,   0))   //=> ', Time.phputc("c",   Time.utc(   0,  0,  1,  0,  0,  0,   0)));
document.writeln('phputc("c",   Time.utc(9999, 11, 31, 23, 59, 59, 999))   //=> ', Time.phputc("c",   Time.utc(9999, 11, 31, 23, 59, 59, 999)));
document.writeln('strfutc("%c", Time.utc(   0,  0,  1,  0,  0,  0,   0))   //=> ', Time.strfutc("%c", Time.utc(   0,  0,  1,  0,  0,  0,   0)));
document.writeln('strfutc("%c", Time.utc(9999, 11, 31, 23, 59, 59, 999))   //=> ', Time.strfutc("%c", Time.utc(9999, 11, 31, 23, 59, 59, 999)));
document.writeln('');

document.writeln('');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('=============================================================== PHPDATE | PHPUTC');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('');

document.writeln('Character Spectrum:');
document.writeln('');
document.writeln('Local:');
document.writeln('  Day      : ', Time.phpdate('d ~ D ~ j ~ l ~ N ~ S ~ w ~ z        '));
document.writeln('  Week     : ', Time.phpdate('W                                    '));
document.writeln('  Month    : ', Time.phpdate('F ~ m ~ M ~ n ~ t                    '));
document.writeln('  Year     : ', Time.phpdate('L ~ o ~ Y ~ y                        '));
document.writeln('  Time     : ', Time.phpdate('a ~ A ~ B ~ g ~ G ~ h ~ H ~ i ~ s ~ u'));
document.writeln('  Timezone : ', Time.phpdate('e ~ I ~ O ~ P ~ T ~ Z                '));
document.writeln('  Full     : ', Time.phpdate('c ~ r ~ U                            '));
document.writeln('');
document.writeln('UTC:');
document.writeln('  Day      : ', Time.phputc('d ~ D ~ j ~ l ~ N ~ S ~ w ~ z        '));
document.writeln('  Week     : ', Time.phputc('W                                    '));
document.writeln('  Month    : ', Time.phputc('F ~ m ~ M ~ n ~ t                    '));
document.writeln('  Year     : ', Time.phputc('L ~ o ~ Y ~ y                        '));
document.writeln('  Time     : ', Time.phputc('a ~ A ~ B ~ g ~ G ~ h ~ H ~ i ~ s ~ u'));
document.writeln('  Timezone : ', Time.phputc('e ~ I ~ O ~ P ~ T ~ Z                '));
document.writeln('  Full     : ', Time.phputc('c ~ r ~ U                            '));
document.writeln('');
document.writeln('');
document.writeln('Unsupported Characters:');
document.writeln('  Timezone : ', Time.phputc('\\e ~ \\T'));
document.writeln('');
document.writeln('');
document.writeln('Equivalents:');
document.writeln('');
document.writeln('phpdate("c")                  //=> ', Time.phpdate("c"));
document.writeln('phpdate("Y-m-d\\TH:i:sP")      //=> ', Time.phpdate("Y-m-d\\TH:i:sP"));
document.writeln('');
document.writeln('phpdate("r")                  //=> ', Time.phpdate("r"));
document.writeln('phpdate("D, d M, Y H:i:s O")  //=> ', Time.phpdate("D, d M Y H:i:s O"));
document.writeln('');

document.writeln('');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('============================================================= STRFTIME | STRFUTC');
document.writeln('--------------------------------------------------------------------------------');
document.writeln('');

document.writeln("JSON Formatting (%FT%T.%NZ): ", Time.strfutc("%FT%T.%NZ"));
document.writeln('');
document.writeln('');
document.writeln('Spectrum:');
document.writeln('');
document.writeln(Time.strftime([
  'Local:',
  '',
  '  Weekday       : %A ~ %a ~ %u (0-6) ~ %w (1-7)',
  '  Month         : %B ~ %b ~ %m',
  '  Day           : %d ~ %e',
  '  Year          : %C ~ %y ~ %Y',
  '',
  '  Hour          : %H (00-23) ~ %k (0-23) ~ %I (01-12) ~ %l (1-12) ~ %p ~ %P',
  '  Minute        : %M',
  '  Second        : %S ~ %s',
  '  Millisecond   : %N',
  '  Timezone      : %z',
  '',
  '  Day of Year   : %j',
  '  Week Number   : %U (Sun-Sat) ~ %W (Mon-Sun)',
  '',
  '  ISO8601 Year  : %g ~ %G',
  '  ISO8601 Week  : %V',
  '',
  '  Date          : %D ~ %F ~ %v',
  '  Time          : %r ~ %R ~ %T',
  '  Locale        : %c',
  '                : %x ~ %X'
].join("%n")));
document.writeln('');
document.writeln(Time.strfutc([
  'UTC:',
  '',
  '  Weekday       : %A ~ %a ~ %u (0-6) ~ %w (1-7)',
  '  Month         : %B ~ %b ~ %m',
  '  Day           : %d ~ %e',
  '  Year          : %C ~ %y ~ %Y',
  '',
  '  Hour          : %H (00-23) ~ %k (0-23) ~ %I (01-12) ~ %l (1-12) ~ %p ~ %P',
  '  Minute        : %M',
  '  Second        : %S ~ %s',
  '  Millisecond   : %N',
  '  Timezone      : %z',
  '',
  '  Day of Year   : %j',
  '  Week Number   : %U (Sun-Sat) ~ %W (Mon-Sun)',
  '',
  '  ISO-8601 Year : %g ~ %G',
  '  ISO-8601 Week : %V',
  '',
  '  Date          : %D ~ %F ~ %v',
  '  Time          : %r ~ %R ~ %T',
  '  Locale        : %c',
  '                : %x ~ %X'
].join("%n")));
document.writeln('');
document.writeln('');
document.writeln('Languages');
document.writeln('');
var langs = Time.langList();
for (var l = 0; l < langs.length; l += 1) {
  Time.langSet(langs[l]);
  document.writeln('  ', langs[l], ': ', Time.strftime('%a ~ %A ~ %b ~ %B'));
}; Time.langReset();
document.writeln('');
document.writeln('');
document.writeln('Completion');
document.writeln('');
document.writeln(Time.strftime('  %%a: %a'));
document.writeln(Time.strftime('  %%A: %A'));
document.writeln(Time.strftime('  %%b: %b'));
document.writeln(Time.strftime('  %%B: %B'));
document.writeln(Time.strftime('  %%c: %c'));
document.writeln(Time.strftime('  %%C: %C'));
document.writeln(Time.strftime('  %%d: %d'));
document.writeln(Time.strftime('  %%D: %D'));
document.writeln(Time.strftime('  %%e: %e'));
document.writeln(Time.strftime('  %%E: %E'));
document.writeln(Time.strftime('  %%F: %F'));
document.writeln(Time.strftime('  %%g: %g'));
document.writeln(Time.strftime('  %%G: %G'));
document.writeln(Time.strftime('  %%h: %h'));
document.writeln(Time.strftime('  %%H: %H'));
document.writeln(Time.strftime('  %%I: %I'));
document.writeln(Time.strftime('  %%j: %j'));
document.writeln(Time.strftime('  %%k: %k'));
document.writeln(Time.strftime('  %%l: %l'));
document.writeln(Time.strftime('  %%m: %m'));
document.writeln(Time.strftime('  %%M: %M'));
document.writeln(Time.strftime('  %%n: \\n'));
document.writeln(Time.strftime('  %%N: %N'));
document.writeln(Time.strftime('  %%O: %O'));
document.writeln(Time.strftime('  %%p: %p'));
document.writeln(Time.strftime('  %%P: %P'));
document.writeln(Time.strftime('  %%r: %r'));
document.writeln(Time.strftime('  %%R: %R'));
document.writeln(Time.strftime('  %%s: %s'));
document.writeln(Time.strftime('  %%S: %S'));
document.writeln(Time.strftime('  %%t: \\t'));
document.writeln(Time.strftime('  %%T: %T'));
document.writeln(Time.strftime('  %%u: %u'));
document.writeln(Time.strftime('  %%U: %U'));
document.writeln(Time.strftime('  %%v: %v'));
document.writeln(Time.strftime('  %%V: %V'));
document.writeln(Time.strftime('  %%w: %w'));
document.writeln(Time.strftime('  %%W: %W'));
document.writeln(Time.strftime('  %%x: %x'));
document.writeln(Time.strftime('  %%X: %X'));
document.writeln(Time.strftime('  %%y: %y'));
document.writeln(Time.strftime('  %%Y: %Y'));
document.writeln(Time.strftime('  %%z: %z'));
document.writeln(Time.strftime('  %%Z: %Z'));
document.writeln(Time.strftime('  %%%%: %%'));
document.writeln('');

document.write('</pre>');

}
</script>

</body>
</html>
